#ifndef SIMPLE_GRAPHICAL_INITIALIZER_H
#define SIMPLE_GRAPHICAL_INITIALIZER_H
#include "simple/sdlcore/initializer.h"

#include "display.h"

namespace simple::graphical
{

	// in general we want this class to not exist and library initialization to be unnecessary
	class initializer : private sdlcore::initializer
	{
		private:

		class screensaver_control
		{
			public:
			screensaver_control() noexcept;
			~screensaver_control() noexcept;
			void keep_alive() noexcept;
			void release_one() noexcept;
			void release_all() noexcept;
			[[nodiscard]] bool kept_alive() const noexcept;
			[[nodiscard]] static bool global_kept_alive() noexcept;
			private:
			int keep_alive_count;
			// TODO: make the global state atomic maybe?
			static int global_keep_alive_count;
		};

		public:
		initializer();

		// the main reason this is here is to change SDL's default by enabling screensaver in the constructor, which SDL just disables, cause idk, it's a game?
		// in contrast to doing it in initializer constructor without the global state, it's impervious to library reinitialization, goes with our theme of pretending that it doesn't exist
		// TODO: all the counting stuff is a bit dubious though, it's a generic thing akin to reference counting, so doesn't feel right to bake it into this API
		screensaver_control screensaver;

		// TODO: no point in this being member though
		display_list displays() const noexcept;
	};

} // namespace simple::graphical

#endif /* end of include guard */
